package com.cooper.controllers.buyer;

import org.springframework.beans.factory.annotation.Autowired;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.rest.Get;

import com.cooper.controllers.Controller;
import com.cooper.controllers.LoginRequired;
import com.cooper.entity.UserInfo;
import com.cooper.service.core.UserService;
import com.cooper.util.Controllers;

/**
 * 
* @Description: 
* @version: v1.0.0
* @author: tianlg
* @date: Mar 5, 2015 2:59:35 PM
*
* Modification History:
* Date         Author          Version            Description
*---------------------------------------------------------*
* Mar 5, 2015      tianlg          v1.0.0
 */
@LoginRequired
public class InformationController extends Controller {

	@Autowired
	private UserService userService;
	
	@Get
	public String execute(Invocation inv) throws Exception{
		UserInfo user = userService.getUser(Controllers.getUserInfo(inv).getUserName());
		inv.addModel("user",user);
		return "InformationMain";
	}
	
	@Get("edit")
	public String edit(Invocation inv) throws Exception{
		UserInfo user = userService.loadById(Controllers.getUserInfo(inv).getId());
		inv.addModel("user",user);
		return "InformationEdit";
	}
}
